package com.example.idachuappone.promptly.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class UserInfo implements Serializable {
    private List<Addresses> addresses;
    private int degree;
    private String name;
    private String phone;
    private String regtime;
    private String uid;

    public void parseJson(JSONObject json) {
        if (json != null) {
            if (json.has("uid")) {
                this.uid = json.optString("uid");
            }
            if (json.has("name")) {
                this.name = json.optString("name");
            }
            if (json.has("phone")) {
                this.phone = json.optString("phone");
            }
            if (json.has("regtime")) {
                this.regtime = json.optString("regtime");
            }
            if (json.has("degree")) {
                this.degree = json.optInt("degree");
            }
            if (json.has("addresses")) {
                try {
                    JSONArray jsonArray = json.optJSONArray("addresses");
                    this.addresses = new ArrayList();
                    for (int i = 0; i < jsonArray.length(); i++) {
                        JSONObject jsonObject = jsonArray.getJSONObject(i);
                        Addresses address = new Addresses();
                        address.parseJson(jsonObject);
                        this.addresses.add(address);
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public String getUid() {
        return this.uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return this.phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getRegtime() {
        return this.regtime;
    }

    public void setRegtime(String regtime) {
        this.regtime = regtime;
    }

    public int getDegree() {
        return this.degree;
    }

    public void setDegree(int degree) {
        this.degree = degree;
    }

    public List<Addresses> getAddresses() {
        return this.addresses;
    }

    public void setAddresses(List<Addresses> addresses) {
        this.addresses = addresses;
    }
}
